/**
 * @Project : algorithm-learning
 * @Author : Ruoyu Wang
 * @User : Momenta
 * @DateTime : 2024/4/16 11:45
 */

#include <iostream>

using namespace std;

class Solution {
public:
    string mergeAlternately(string word1, string word2) {
        int i1 = 0;
        int i2 = 0;
        int tag = 0;
        string res = "";
        while (i1 < word1.size() && i2 < word2.size()) {
            if (tag % 2) res += word2[i2++];
            else res += word1[i1++];
            tag++;
        }
        for (int i = i1; i < word1.size(); ++i) {
            res += word1[i];
        }
        for (int i = i2; i < word2.size(); ++i) {
            res += word2[i];
        }
        return res;
    }
};